package com.wf.model.exception;

import com.wf.model.enums.ResultCode;

import java.util.Objects;

public class WorkflowException extends RuntimeException {

  private static final long serialVersionUID = 1L;

  private final ResultCode code;

  public WorkflowException(ResultCode ec, String message, Throwable cause) {
    super(message, cause);
    code = ec;
  }

  public WorkflowException(ResultCode ec, String message) {
    this(ec, message, null);
  }

  public WorkflowException(ResultCode ec, Throwable cause) {
    this(ec, null, cause);
  }

  public ResultCode getCode() {
    return code;
  }

  public static void throwWorkFlowException(String msg){
    if (Objects.isNull(msg)){
      msg = "参数有误";
    }
    throw new WorkflowException(ResultCode.INVALID_ARGUMENT,msg);
  }
}